home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_004 / bm / mkdescvec.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  694b  |  33 lines

  1. #include "bm.h"
  2.  
  3. #ifdef BSD
  4. #include <strings.h>
  5. #else
  6. #define index strchr
  7. #include <string.h>
  8. #endif
  9.  
  10. /* scan a newline-separated string of patterns and set up the
  11. * vector of descriptors, one pattern descriptor per pattern. 
  12. * Return the number of patterns */
  13. int
  14. MkDescVec(DescVec, Pats)
  15. struct PattDesc *DescVec[];
  16. char *Pats;
  17. {
  18.     int NPats = 0;
  19.     char *EndPat;
  20.     extern struct PattDesc *MakeDesc();
  21.     while (*Pats && (EndPat = index(Pats,'\n')) && NPats < MAXPATS) {
  22.         *EndPat = '\0';
  23.         DescVec[NPats] = MakeDesc(Pats);
  24.         Pats = EndPat + 1;
  25.         ++NPats;
  26.     } /* while */
  27.     if (*Pats && NPats < MAXPATS) {
  28.         DescVec[NPats] = MakeDesc(Pats);
  29.         ++NPats;
  30.     } /* if */
  31.     return(NPats);
  32. } /* MkDescVec */
  33.